<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/2
 * Time: 10:54
 */

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
class BankCard extends Model
{
    /**
     * 用户银行卡
     * @var string
     */
    protected $table = 'bank_card';

    protected $fillable = [
        'id',
        'uid',
        'phone',
        'name',
        'bank_name',
        'card_number',
        'bank_address',
    ];
    /**
     * 统计银行卡数量
     * @param null $uid
     * @return int
     */
    public function count_bank($uid = null) {
        return $this->where(['uid' => $uid])->count();
    }

    /**
     * 获取银行卡
     * @param null $uid
     * @return bool|Model|null|static
     */
    public function get_bank($uid = null) {
        $rico = $this->where(['uid' => $uid])->get()->toArray();
        if ($rico) {
            return $rico;
        } else {
            return false;
        }
    }
}